<?php
namespace app\controller;

use app\BaseController;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;
class Index extends BaseController
{

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }

    public function edit(){
        $id = Request::param('id');
        $shop = Db::table('book')->where('id',$id)->find();
        $cat = Db::table('book_cate')->where('status',1)->select();
        View::assign([
            'shop' => $shop,
            'cat' => $cat
        ]);
        return View::fetch();
    }
    public function edits(){
        // print_r( Request::param() );
        // print_r( Request::post() );

        $all = Request::param();
        $update = Db::table('shop_goods')->where('id',$all['id'])->update($all);
        if($update){
            echo json_encode(['code'=>0,'msg'=>'修改成功']);
        }else{
            echo json_encode(['code'=>1,'msg'=>'修改失败']);
        }
    }
}
